from machine import Pin,SPI
from ssd1351 import Display
import camera
spi = SPI(2, baudrate=14500000, sck=Pin(2), mosi=Pin(14))
display = Display(spi, dc=Pin(15), cs=Pin(13), rst=Pin(12),width=128,height=128)
camera.init(0,format=0)

ecc=camera.capture()
ee=ecc.resize(128,96)#修改大小 128X128的屏幕没买，手头上只有128x96屏幕
q=ee.find_circles(threshold = 3500, x_margin = 10, y_margin = 10, r_margin = 10,r_min = 2, r_max = 100, r_step = 2)

#find_rects 下 若文件使用resize再使用查找方块，会导致重启bug，可以先查找再resize
for c in q:
    ee.draw_circle(c.x(), c.y(), c.r(), color = (0, 255, 0))
display.draw_image_ram(ee.to_bytes(), 0, 30, 128, 96)

